package com.gh.util;

import com.gh.helper.JwtHelper;

import javax.servlet.http.HttpServletRequest;

/**
 * @Author Eric
 * @Date 2021/6/20 21:22
 * @Version 1.0
 * 获取当前用户信息
 */
public class AuthContextHolder {
    //获取当前用户id
    public static Long getUserId(HttpServletRequest request){
        String token = request.getHeader("token");
        Long userId = JwtHelper.getUserId(token);
        return userId;
    }
    //获取当前用户名称
    public static String getUsername(HttpServletRequest request){
        String token = request.getHeader("token");
        String userName = JwtHelper.getUserName(token);
        return userName;
    }
}
